# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo9.08
# Description:
# Author:       $赵怡蕾
# Date:         2019/3/5
#-------------------------------------------------------------------------------

# 未抛出异常时执行finally子句中的代码
def fun1():
    try:
        print("fun1 正常执行")
    finally:
        print("fun1 finally")
# 抛出异常时执行finally子句中的代码
def fun2():
    try:
        raise Exception
    except:
        print("fun2 抛出异常")
    finally:
        print("fun2 finally")
# 用return语句退出函数之前执行finally子句中的代码
def fun3():
    try:
        return 20
    finally:
        print("fun3 finally")
# 抛出异常时执行finally子句中的代码，但在finally子句中执行del x操作，再一次抛出了异常
def fun4():
    try:
        x = 1/0
    except ZeroDivisionError as e:
        print(e)
    finally:
        print("fun4 finally")
        del x
fun1()
fun2()
print(fun3())
fun4()